package edu.task.mapper;

import edu.task.model.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;

@org.apache.ibatis.annotations.Mapper
public interface Mapper {
    @Insert("insert into sys_user( " +
            "user_name, nick_name, email, phonenumber, sex, password, status, del_flag, create_by, create_time, update_by, update_time, remark) " +
            "values (#{userName}, #{nickName}, #{email}, #{phonenumber}, #{sex}, #{password}, #{status}, " +
            "#{delFlag}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{remark})")
    @Options(keyProperty="userId", keyColumn="user_id", useGeneratedKeys=true)
    void insertUser(SysUser sysUser);

    @Insert("insert into sys_role( " +
            "role_name, role_key, status, del_flag, create_by, create_time, update_by, update_time, remark) " +
            "values (#{roleName}, #{roleKey}, #{status}, " +
            "#{delFlag}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{remark})")
    @Options(keyProperty="roleId", keyColumn="role_id", useGeneratedKeys=true)
    void insertRole(SysRole sysRole);


    @Insert("insert into sys_project( " +
            "project_name, project_type, status, create_by, create_time, update_by, update_time, remark) " +
            "values (#{projectName}, #{projectType}, #{status}, " +
            "#{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{remark})")
    @Options(keyProperty="projectId", keyColumn="project_id", useGeneratedKeys=true)
    void insertProject(SysProject sysProject);

    @Insert("insert into sys_task( " +
            "task_name, working_hours, conscientious, status, create_by, create_time, update_by, update_time, remark) " +
            "values (#{taskName}, #{workingHours}, #{conscientious}, #{status}, " +
            "#{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{remark})")
    @Options(keyProperty="taskId", keyColumn="task_id", useGeneratedKeys=true)
    void insertTask(SysTask sysTask);

    @Insert("insert into sys_explain( content ) values (#{content})")
    @Options(keyProperty="explainId", keyColumn="explain_id", useGeneratedKeys=true)
    void insertExplain(SysExplain sysExplain);

    @Insert("insert into sys_subtask( " +
            "subtask_name, status) " +
            "values (#{subtaskName}, #{status})")
    @Options(keyProperty="subtaskId", keyColumn="subtask_id", useGeneratedKeys=true)
    void insertSubtask(SysSubtask sysSubtask);

    @Insert("insert into sys_msg( status, content ) values (#{status}, #{content})")
    @Options(keyProperty="msgId", keyColumn="msg_id", useGeneratedKeys=true)
    void insertMsg(SysMsg sysMsg);
}
